import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author liushan
 * Created by liushan on 2019-04-09.
 */
@WebFilter(filterName = "DgutFilter")
public class DgutFilter extends HttpFilter {
    @Override
    protected void doFilter(HttpServletRequest req, HttpServletResponse res, FilterChain chain) throws IOException, ServletException {

        res.setContentType("application/json");
        res.setCharacterEncoding("UTF-8");
        System.out.println(this.getClass());

        String token = req.getParameter("token");
        if(token==null)
        {res.sendRedirect("https://cas.dgut.edu.cn?appid=javaee&state=STATE");}

        else chain.doFilter(req,res);
    }
}